#ifndef  _HARDWARE_FLASH_H
#define  _HARDWARE_FLASH_H

#include "system_ch32v30x.h"
#include "lfs.h"

void flash_hardware_init(void);
uint16_t flash_read_w25q128_id(void);
void flash_write_bytes(const uint8_t* buffer,uint32_t addr,uint16_t num);
void flash_read_bytes(uint8_t* buffer,uint32_t addr,uint16_t num);
void flash_erase_sector(uint32_t addr);
uint8_t flash_read_status_registers(void);


int flash_read_littlefs(const struct lfs_config *c, lfs_block_t block,
            lfs_off_t off, void *buffer, lfs_size_t size);
int flash_write_littlefs(const struct lfs_config *c, lfs_block_t block,
           lfs_off_t off, const void *buffer, lfs_size_t size);
int flash_erase_littlefs(const struct lfs_config *c, lfs_block_t block);
int flash_sync_littlefs(const struct lfs_config *c);

#endif
